package com.grade.controller;

import com.grade.domain.Course;
import com.grade.domain.CourseDto;
import com.grade.domain.Response;
import com.grade.domain.StudentGradeDto;
import com.grade.service.CourseService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
public class courseController {
    @Resource
    private CourseService courseService;

    //根据学生id查询学生课程成绩
    @RequestMapping("/course/grade")
    public Response<List<CourseDto>> getCourseById(@RequestParam Integer id, @RequestParam String da){
        return courseService.getCourseById(id,da);
    }
    //根据老师id查询学生课程成绩
    @RequestMapping("/course/grade/teacher")
    public Response<List<StudentGradeDto>> getCourseGradeByTeacherId(@RequestParam Integer id,@RequestParam String courseName){
        return courseService.getCourseGradeByTeacherId(id,courseName);
    }
    //根据老师id查询课程
    @RequestMapping("/course/teacher")
    public Response<List<Course>> getCourseByTeacherId(@RequestParam Integer id){
        return courseService.getCourseByTeacherId(id);
    }
    //修改成绩
    @RequestMapping("/course/grade/update")
    public Response<String> updateCourseGrade(@RequestBody Course course){
        return courseService.updateCourseGrade(course);
    }
    //添加成绩
    @RequestMapping("/course/grade/add")
    public Response<String> addCourseGrade(@RequestBody Course course){
        return courseService.addCourseGrade(course);
    }
}
